<script>
    function reportundefined() {

        $(".preload").css('display', 'block');
<?php if ($this->session->userdata('level') == 1): ?>
            var link = 'reporting-system';
<?php elseif ($this->session->userdata('level') == 2): ?>
            var link = 'reporting-agency';
<?php elseif ($this->session->userdata('level') == 3): ?>
            var link = 'reporting-user';
<?php elseif ($this->session->userdata('level') == 4): ?>
            var link = 'reporting-agency-place';
<?php endif; ?>

        var url_report = '<?php echo $baseurl; ?>' + link;
        OpenPopup(url_report, 650, 990);
    }
    function OpenPopup(popUrl, heights, widths) {
        var popUrl = popUrl;
        window.scrollTo(0, 0);
        var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
        var height = document.documentElement.clientHeight + document.documentElement.scrollTop;
        var layer = document.createElement("div");
        layer.style.zIndex = 999;
        layer.id = "layer";
        layer.style.position = "absolute";
        layer.style.top = "0px";
        layer.style.left = "0px";
        layer.style.height = document.documentElement.scrollHeight + "px";
        layer.style.width = width + "px";
        layer.style.backgroundColor = "black";
        layer.style.opacity = "0.75";
        layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=75)");
        document.body.style.position = "static";


        document.body.appendChild(layer);
        var iframe = document.createElement("iframe");

        iframe.name = "Export excel by nhatnv";
        iframe.id = "popup";
        iframe.src = popUrl;
        iframe.style.height = heights + "px";
        iframe.style.width = widths + "px";
        iframe.style.position = "fixed";
        iframe.style.zIndex = 999999;
        iframe.style.backgroundColor = "white";
        iframe.frameborder = "0";
        iframe.style.top = ((height + document.documentElement.scrollTop) / 2) - (heights / 2) + "px";
        iframe.style.left = (width / 2) - (widths / 2) + "px";
        document.body.appendChild(iframe);
    }
    function ClosePop() {
        var layer = document.getElementById("layer");
        var iframe = document.getElementById("popup");
        document.body.removeChild(layer); // remove layer
        document.body.removeChild(iframe); // remove div
    }
    function closeIframe() {
        //window.parent.ClosePop();
    }
</script>
<div id="sidebar">
    <ul>
        <li class="user">
            <div class="logo">
                <a href="<?php echo $baseurl.'setting.html';?>"><img style="width: 100%;" src="<?php echo $this->session->userdata('img') ? $baseurl.$this->session->userdata('img') : $baseurl.'public/assets/images/avatar.png'; ?>" 
				onError="this.src='<?php echo $baseurl."public/assets/images/avatar.png";?>'"
				/> </a>
            </div>
            <p>Xin chào <?php echo $this->session->userdata('fullname')?></p>
            <p>Số dư <span style="color: #ff6600"><?php echo number_format($this->session->userdata('money'))?></span></p>
            
        </li>

        <li <?php echo ($controller == 'index' && $action == 'index') || ($controller == 'campaignagency' && $action == 'report') || ( $controller == 'campaignagencyplace' && $action == 'report' ) || ($controller == 'campaignuser' && $action == 'report') ? 'class="active"' : '' ?>>
            <a href="<?php echo $baseurl . 'index.html' ?>">
                <i class="icon-statistics big"></i>
                <label>Thống kê nhanh</label>
            </a>
        </li>

        <?php if ($this->session->userdata('level') == 1): ?>
            <li <?php
            if (in_array($controller, array('campaign')) && !in_array($action, array('report'))) {
                echo 'class="active"';
            }
            ?>>
                <a href="<?php echo $baseurl . 'campaign/cho-duyet.html' ?>">
                    <i class="icon-campaign big"></i>
                    <label>Chiến dịch</label>
                </a>
            </li>
            <?php elseif ($this->session->userdata('level') == 2): ?>
            <li <?php
            if (in_array($controller, array('campaignagency')) && !in_array($action, array('report', 'placeagency'))) {
                echo 'class="active"';
            }
            ?>>
                <a href="<?php echo $baseurl . 'campaign-agency/dia-diem.html' ?>">
                    <i class="icon-campaign big"></i>
                    <label>Chiến dịch</label>
                </a>
            </li>
            <?php elseif ($this->session->userdata('level') == 3): ?>
            <li <?php
            if (in_array($controller, array('campaignuser')) && !in_array($action, array('report', 'placeuser'))) {
                echo 'class="active"';
            }
            ?>>
                <a href="<?php echo $baseurl . 'campaign-user.html' ?>">
                    <i class="icon-campaign big"></i>
                    <label>Chiến dịch</label>
                </a>
            </li>
        <?php endif; ?>
        <li <?php echo ($controller == 'index' && $action == 'place' || $action == 'detail') || ($controller == 'campaignagency' && $action == 'placeagency') || ($controller == 'campaignagencyplace' && $action == 'placeagencyplace') || ($controller == 'campaignuser' && $action == 'placeuser')  ? 'class="active"' : '' ?>>
            <a href="<?php echo $baseurl . 'place.html' ?>">
                <i class="icon-place big"></i>
                <label>Địa điểm</label>
            </a>
        </li>
        <?php if (in_array($this->session->userdata('level'), array('1', '2', '3'))) { ?> 
            <li>
                <a onclick="reportundefined()" style="cursor: pointer;">
                    <i class="icon-report big"></i>
                    <label>Báo cáo</label>
                </a>
            </li>
        <?php } ?>
        <li <?php echo ($controller == 'user' || $controller == 'classify') ? 'class="active"' : '' ?>>
            <a href="<?php echo $baseurl . 'setting.html' ?>">
                <i class="icon-setting big"></i>
                <label>Cài đặt</label>
            </a>
        </li>
        <li>
        <p><a class="logout" href="<?php echo $baseurl.'logout.html'?>"><span class="icon-logout small"></span> <span>Logout</span></a></p>
        </li>
    </ul>
</div>